<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>书籍列表</title>
    <style>
        .odd { background-color:#f0f0f0; } /*奇数行背景色*/
        .even{ background-color:#ffffff; } /*偶数行背景色*/
    </style>
</head>
<body>
<table border="1">
    <thead>
        <tr>
            <th>序号</th>
            <th>书名</th>
            <th>作者</th>
            <th>价格</th>
            <th>书名是否改变</th>
        </tr>
    </thead>
    <tbody>
        {% for book in books %}
        <tr class="{{ loop.cycle('odd','even') }}">
            <td>{{ loop.index }}</td>
            <td>{{ book.name }}</td>
            <td>{{ book.author }}</td>
            <td>{{ book.price }}元</td>
            <td>{% if loop.frist or (book.name != last_book_name) %}
                是
                {% else %}
                否
                {% endif %}
            </td>
        </tr>
        {% set last_book_name = book.name %}
        {% endfor %}
    </tbody>
</table>
</body>
</html>